package com.dj.mingkong.admin.biz.controller.music;

import com.dj.mingkong.admin.biz.controller.music.vo.request.BoxQueryVo;
import com.dj.mingkong.admin.biz.controller.music.vo.request.BoxUpdateVo;
import com.dj.mingkong.admin.biz.controller.music.vo.response.BoxVo;
import com.dj.mingkong.admin.biz.service.music.BoxService;
import com.dj.mingkong.common.annotation.HasRoles;
import com.dj.mingkong.common.enums.RoleEnum;
import com.dj.mingkong.common.infrastructure.base.dto.delete.DeleteVo;
import com.dj.mingkong.common.infrastructure.base.dto.page.PageVo;
import com.dj.mingkong.common.infrastructure.base.dto.rest.RestResponse;
import com.dj.mingkong.common.util.AssertUtils;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 音乐盒管理
 *
 * @author zenglonghui
 * @date: 2022/12/13 16:49
 */
@RestController
@RequestMapping("/box")
@HasRoles(RoleEnum.ADMIN)
public class BoxController {
    @Resource
    private BoxService boxService;

    /**
     * 音乐盒列表查询
     *
     * @param queryVo {}
     * @return BoxVo
     */
    @PostMapping("/pageByVo")
    public RestResponse<PageVo<BoxVo>> pageByVo(@RequestBody BoxQueryVo queryVo) {
        AssertUtils.checkQueryPageVo(queryVo);
        return RestResponse.success(boxService.pageByVo(queryVo));
    }

    /**
     * 修改数据
     *
     * @param updateVo {}
     * @return Boolean
     */
    @PostMapping("/updateById")
    public RestResponse<Boolean> updateById(@RequestBody @Validated BoxUpdateVo updateVo) {
        boxService.updateById(updateVo);
        return RestResponse.buildSuccess();
    }

    /**
     * 删除数据
     *
     * @param deleteVo {}
     * @return Boolean
     */
    @PostMapping("/deleteById")
    public RestResponse<Boolean> deleteById(@RequestBody @Validated DeleteVo deleteVo) {
        boxService.deleteById(deleteVo);
        return RestResponse.buildSuccess();
    }

}
